Representing Different Qubit States¶
1. Creating Two-Dimensional Vectors for |0⟩ and |1⟩ States¶
In quantum computing, the basis states $|0\rangle$ and $|1\rangle$ are represented as two-dimensional vectors. These vectors can be written in Dirac notation as follows:
- $$ |0\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix} $$
- $$ |1\rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix} $$
# Vector representing the |0⟩ state
zero_state = [1, 0]
# Vector representing the |1⟩ state
one_state = [0, 1]
2. Representing the Vector to Dirac Notation¶
In quantum computing, vectors can be converted to Dirac notation. Using Cirq, we can represent quantum states and convert them accordingly.
As an example, cirq.dirac_notation(zero_state) converts the zero_state vector to Dirac notation:
import cirq
print(cirq.dirac_notation(zero_state))
print(cirq.dirac_notation(one_state))
|0⟩ |1⟩
3.Bloch Sphere Representation¶
We can visualize a quantum state on a Bloch sphere using Cirq Web, we can use the BlochSphere class from cirq_web. Here's how to display it in a Jupyter notebook:
from cirq_web import BlochSphere
bloch_sphere_at_zero_state = BlochSphere(state_vector=zero_state, sphere_radius=4)
bloch_sphere_at_one_state = BlochSphere(state_vector=one_state, sphere_radius=4)
print("BlochSphere representing 0 state: ")
display(bloch_sphere_at_zero_state)
print("BlochSphere representing 1 state: ")
display(bloch_sphere_at_one_state)
BlochSphere representing 0 state:
BlochSphere representing 1 state:
Creating Superposition States¶
In quantum computing, a superposition state is a combination of basis states with specific coefficients.
Here, we'll create the superposition states $$ |+\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle) $$ and $$ |-\rangle = \frac{1}{\sqrt{2}}(|0\rangle - |1\rangle) $$
1. Creating $|+\rangle$ state and Representing it :¶
import numpy as np
plus_sate = [1/np.sqrt(2), 1/np.sqrt(2)]
print("Representing Plus State in Dirac notation: ")
display(cirq.dirac_notation(plus_sate))
bloch_sphere_at_plus_state = BlochSphere(state_vector=plus_sate, sphere_radius=4)
print("\n\nBlochSphere representing + state: ")
display(bloch_sphere_at_plus_state)
Representing Plus State in Dirac notation:
'0.71|0⟩ + 0.71|1⟩'
BlochSphere representing + state:
2. Creating $|-\rangle$ state and Representing it :¶
minus_sate = [1/np.sqrt(2), -1/np.sqrt(2)]
print("Representing minus State in Dirac notation: ")
display(cirq.dirac_notation(minus_sate))
bloch_sphere_at_minus_state = BlochSphere(state_vector=minus_sate, sphere_radius=4)
print("\n\nBlochSphere representing - state: ")
display(bloch_sphere_at_minus_state)
Representing minus State in Dirac notation:
'0.71|0⟩ - 0.71|1⟩'
BlochSphere representing - state:
Practice Question¶
- Create a vector that has a $\frac{1}{3}$ chance of being measured in the $|0\rangle$ state and $\frac{2}{3}$ chance of being measured in the $|1\rangle$ state.
- Represent the state using ket notation and describe its representation on the Bloch sphere.
# Solve ->
random_state = [1/np.sqrt(3), np.sqrt(2)/np.sqrt(3)]
print("Representing the State in Dirac notation: ")
display(cirq.dirac_notation(random_state))
bloch_sphere_at_random_state = BlochSphere(state_vector=random_state, sphere_radius=4)
print("\n\nBlochSphere representing Random state: ")
display(bloch_sphere_at_random_state)
Representing the State in Dirac notation:
'0.58|0⟩ + 0.82|1⟩'
BlochSphere representing Random state:
The components of the state vector $[\frac{1}{\sqrt{3}}, \frac{\sqrt{2}}{\sqrt{3}}]$ can be squared to understand the probability distribution of the quantum state:
The probability of measuring the qubit in the state $|0\rangle$ is $\left(\frac{1}{\sqrt{3}}\right)^2 = \frac{1}{3}$.
The probability of measuring the qubit in the state $|1\rangle$ is $\left(\frac{\sqrt{2}}{\sqrt{3}}\right)^2 = \frac{2}{3}$.
This illustrates a probabilistic quantum state where measurements will yield the $|0\rangle$ state with a probability of $\frac{1}{3}$ and the $|1\rangle$ state with a probability of $\frac{2}{3}$.